#include <iostream>
#include <cmath>
#include <stdfin/nintegrate/gauss_legendre.hpp>

double f(double x) 
{
    return 1./(1+x); 
}

// Normal probability density function
struct normal_pdf
{
    double _mu;
    double _sigma;
    
    double operator()(double x) const
    {
        double z = (x - _mu) / _sigma;
        return 0.39894228 * std::exp( -0.5*z*z) / _sigma;
    }
};


int main()
{
    std::cout << "int_0^1 1/(1+x) dx = " 
              << stdfin::gauss_legendre_16(f, 0, 1) 
              << std::endl;

    normal_pdf pdf = {0.3, 1.4};
    std::cout << "integral of the standard normal density from -1 to 1 = " 
              << stdfin::gauss_legendre_32(pdf, -1, 1) 
              << std::endl;

    return 0;
}